*** Settings ***
Library    Canoelibrary
Library    Real_Button
Library    Compare_Image
Library    ADBScreenControllerLibrary
Library    ocr
Library    Fault_Inject
Library    AndroidAudioPlayerLibrary
Library    flash
Library    ADBScreenshot

*** Variables ***
${CANOE_CONFIG_PATH}    C:\\path\\to\\your\\canoe_config.cfg  # 替换为你的CANoe配置文件路径

*** Keywords ***
初始化CANoe
    Initialize_Canoe

启动 CANoe 应用程序
    Start Canoe

加载 CANoe 配置
    Load Configuration

启动 CANoe 测量
    Start Measurement

停止 CANoe 测量
    Stop Measurement

获取信号值
    [Arguments]    ${signal_name}
    ${value}=    Get Signal Value    ${signal_name}
    RETURN    ${value}

关闭 CANoe 应用程序
    Close Canoe

比较图像
    [Arguments]    ${image_path_a}    ${image_path_b}
    ${mse}    ${ssim}    Compare Images    ${image_path_a}    ${image_path_b}
    [Return]    ${mse}    ${ssim}

点击开关进入AVM
    Access To Avm

转向联动进入AVM
    Stalk To Avm

Get And Parse UI Tree
    [Documentation]    获取 UI 树并解析指定 resource-id 元素的坐标
    [Arguments]    ${resource_id}    ${ui_tree_file=window_dump.xml}
    ${ui_tree_file}=    Get UI Tree    ${ui_tree_file}
    ${x}    ${y}=    Parse UI Tree    ${ui_tree_file}    ${resource_id}
    Return From Keyword        ${x}    ${y}

根据ID点击图标
    [Documentation]    根据 resource-id 查找元素并点击
    [Arguments]    ${resource_id}    ${ui_tree_file=window_dump.xml}  # 添加参数定义
    ${x}    ${y}=    Get And Parse UI Tree    ${resource_id}    ${ui_tree_file}
    Click Element    ${x}    ${y}

在设备上播放语音文件
    [Arguments]    ${device_file_path}
    Play Audio File    ${device_file_path}

模拟泊车故障
    Apa Fault Inject

从图像中提取文字
    [Arguments]    ${image_path}    ${lang}=chi_sim    ${config}=None
    ${text}=    OCR From Image    ${image_path}    lang=${lang}    config=${config}
    [Return]    ${text}

滑屏
    [Arguments]    ${start_x}    ${start_y}    ${end_x}    ${end_y}    ${duration}=200
    Swipe Screen    ${start_x}    ${start_y}    ${end_x}    ${end_y}    ${duration}

测试
    Ecu Flash

ADB调用
    Run Adb Command

截全屏
    Take Full Screenshot

裁剪图片
    Crop Screenshot

本地获取图片
    Pull Screenshot

删除设备文件
    Delete File

二坐标截屏
    Take Partial Screenshot
